package fan.adbardemo;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;


import java.util.ArrayList;
import java.util.List;

import fan.adbardemo.view.MarqueeView;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        MarqueeView mMarquee1 = (MarqueeView) findViewById(R.id.mv_bar1);
        MarqueeView mMarquee2 = (MarqueeView) findViewById(R.id.mv_bar2);


        //设置集合
        List<String> items = new ArrayList<>();
        items.add("这是第1个");
        items.add("这是第2个");
        items.add("这是很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长的第3个");
        items.add("这是第4个");
        items.add("这是第5个");
        items.add("这是第6个");
        items.add("这是第7个");
        mMarquee1.startWithList(items);

        //设置字符串
        String str = "这是一段很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长的一段话，是不是很长？";
        mMarquee2.startWithText(str);


        mMarquee1.setOnItemClickListener(new MarqueeView.OnItemClickListener() {
            @Override
            public void onItemClick(int position, TextView textView) {
                Toast.makeText(MainActivity.this, textView.getText().toString(), Toast.LENGTH_SHORT).show();
            }
        });

        mMarquee2.setOnItemClickListener(new MarqueeView.OnItemClickListener() {
            @Override
            public void onItemClick(int position, TextView textView) {
                Toast.makeText(MainActivity.this, textView.getText().toString(), Toast.LENGTH_SHORT).show();
            }
        });

    }
}
